package mao.thinkinjava.concurency.countdownlatch;
import java.util.concurrent.CountDownLatch;

//等待分步任务完成的线程
public class WaitThread implements Runnable {
    private static int counter=0;
    private final int id = counter++;
    private final CountDownLatch latch;

    public WaitThread(CountDownLatch latch) {
        this.latch = latch;
    }

    @Override
    public void run()  {
        try{
            latch.await();
            System.out.println(this+" has in the prepared queue");
        }catch (InterruptedException e){
            e.printStackTrace();
        }

    }

    @Override
    public String toString() {
        return "WaitThread{" +
                "id=" + id +
                '}';
    }
}
